home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d20 / wnode21.arc / WNODE.PAS < prev    next >
Pascal/Delphi Source File  |  1992-01-15  |  22KB  |  680 lines

  1. Unit WNode;
  2. {$O+;$R-;F+}
  3.  
  4. {****************************************************************************}
  5. {      Window nodelist handler for editors,mailers and mail processors       }
  6. {         Copyright 1991 by Silvan Calarco (2:334/100.2@fidonet.org)         }
  7. {****************************************************************************}
  8.  
  9. {****************************************************************************}
  10. { This unit may be used in your programs and is distributed to favour the    }
  11. { diffusion of an unique nodelist format. The nodelist compiler program is   }
  12. { called WNODE.EXE and is availaible either in the packed that contains      }
  13. { this unit and in SDS network.                                              }
  14. { The structures of W-Nodelist are in file WNSTRUCT.DOC.                     }
  15. {                                                                            }
  16. { HOW TO USE THIS UNIT ------------------------------------------------------}
  17. {                                                                            }
  18. { First thing to do is initializing nodelist files by calling:               }
  19. {                                                                            }
  20. { Function InitNodeList(DirName:String):Boolean;                             }
  21. {                                                                            }
  22. { Where DirName is the full path of the directory containing *.WNL files.    }
  23. { This function returns false if one of nodelist files is missing.           }
  24. {                                                                            }
  25. { Using W-Nodelist two sort of shearches can be made:                        }
  26. { 1) By Sysop's name with FindFirstSysop and FindNextSysop                   }
  27. { 2) By Node number with FindFirstNode and FindNextNode                      }
  28. {                                                                            }
  29. { Before performing any sort of search, you have to declare a variable       }
  30. { of type FindNodeRec. The filosophy of this method is very similar to       }
  31. { the one used by TP's FindFirst/FindNext procedures, so FindNodeRec has     }
  32. { the same purpose of SearchRec in unit DOS of TP.                           }
  33. { Inquire results will be returned in FindNodeRec.BBSRecord, a record        }
  34. { which contains these informations:                                         }
  35. {                                                                            }
  36. { BBSRecord=Record                                                           }
  37. {              NodeType:Byte;                                                }
  38. {              Zone,Net,Node,Point:Integer;                                  }
  39. {              BBSName:String[30];                                           }
  40. {              SysopName:String[30];                                         }
  41. {              Location:String[30];                                          }
  42. {              Phone:String[18];                                             }
  43. {              BaudRate:Word;                                                }
  44. {              Flags:String[30];                                             }
  45. {           end;                                                             }
  46. {                                                                            }
  47. { NODETYPE contains one of the following values:                             }
  48. {                                                                            }
  49. {  ZC=1; REGION=2; HOST=4; HUB=8; PVT=16; INHOLD=32; DOWN=64; BOSS=128       }
  50. {                                                                            }
  51. { Other fields contents are the image of what appears in nodelist.           }
  52. {                                                                            }
  53. {----------------------------------------------------------------------------}
  54. {                                                                            }
  55. { 1) FindFirstSysop/FindNextSysop                                            }
  56. {                                                                            }
  57. { To look for one or more entries knowing sysop's name call first time:      }
  58. {                                                                            }
  59. { Procedure FindFirstSysop(SubStr:String;Var Find:FindNodeRec);              }
  60. {                                                                            }
  61. { Where SubStr is the case unsensitive match string for sysop's name.        }
  62. { Note that a name like "John Mc Gregor" is converted in "GREGOR MC JOHN"    }
  63. { for search. This means that match string "MC GREGOR" wouldn't return       }
  64. { the desired entry.                                                         }
  65. {                                                                            }
  66. { To continue search use:                                                    }
  67. {                                                                            }
  68. { Procedure FindNextSysop(Var Find:FindNodeRec);                             }
  69. {                                                                            }
  70. { If Find.BBSRecord.SysopName='' it means that there are no more entries.    }
  71. {                                                                            }
  72. {----------------------------------------------------------------------------}
  73. {                                                                            }
  74. { 2) FindFirstNode/FindNextNode                                              }
  75. {                                                                            }
  76. { To look for one or more entries knowing address call first time:           }
  77. {                                                                            }
  78. { Procedure FindFirstNode(Zone,Net,Node,Point:Integer;Var Find:FindNodeRec); }
  79. {                                                                            }
  80. { Where Zone,Net,Node,Point contain the address of the node to look for.     }
  81. { If you want to look for more than one entry, you can assign one of address }
  82. { fields the value of "ALL" constant. E.g.:                                  }
  83. {                                                                            }
  84. { Zone:=ALL                      looks for every node in database            }
  85. { Zone:=2; Net:=334; Node:=ALL   looks for every node in zone 2, net 334     }
  86. {                                                                            }
  87. { To continue search use:                                                    }
  88. {                                                                            }
  89. { Procedure FindNextSysop(Var Find:FindNodeRec);                             }
  90. {                                                                            }
  91. { If Find.BBSRecord.SysopName='' it means that there are no more entries.    }
  92. {                                                                            }
  93. { You you don't want many files to be open at same time, you can call:       }
  94. {                                                                            }
  95. { Procedure CloseNodeListFiles;                                              }
  96. {                                                                            }
  97. { after any search. FindFirstNode/FindFirstSysop will open them again if     }
  98. { they are closed.                                                           }
  99. {                                                                            }
  100. {****************************************************************************}
  101.  
  102.  
  103. Interface
  104. Const
  105.    { List of kinds of entryes specified in BBSRecord.NodeType }
  106.    ZC=1;
  107.    REGION=2;
  108.    HOST=4;
  109.    HUB=8;
  110.    PVT=16;
  111.    INHOLD=32;
  112.    DOWN=64;
  113.    BOSS=128;
  114.    ALL=-1; { Used to select global nodes with FindFirstNode }
  115.  
  116. Type
  117.    BBSRec=Record                 { Record containing nodelist informations }
  118.              NodeType:Byte;
  119.              Zone,Net,Node,Point:Integer;
  120.              BBSName:String[30];
  121.              SysopName:String[30];
  122.              Location:String[30];
  123.              Phone:String[18];
  124.              BaudRate:Word;
  125.              Flags:String[30];
  126.           end;
  127.  
  128.    NodeLocRec=Record             { Record of NODELOC.WNL }
  129.                  NodeType:Byte;
  130.                  Zone,Net,Node,Point:Integer;
  131.                  FileNum:Byte;
  132.                  FilePos:Longint;
  133.               end;
  134.    SysopRec=Record               { Record of SYSLIST.WNL }
  135.                Name:String[20];
  136.                BBSRecord:Longint;
  137.             end;
  138.    NodeRec=Record                { Record of NODEIDX.WNL }
  139.               NodeType:Byte;
  140.               Number:Integer;
  141.               BBSRecord:Longint;
  142.               Match:Array[1..4] of Char;
  143.               SysopRecord:Longint;
  144.            end;
  145.  
  146.    FindNodeRec=Record            { Used by FindFirstNode/FindFirstSysop }
  147.                   BBSRecord:BBSRec;
  148.                   SZone,SNet,SNode,SPoint:Integer;
  149.                   SysStr:String[30];
  150.                   FPos,FPos1:Longint;
  151.                end;
  152.  
  153. Var
  154.    NodeLocFile:File of NodeLocRec;
  155.    SysopListFile:File of SysopRec;
  156.    NodeIdxFile:File of NodeRec;
  157.    Nodelist1,NodeList2:File;
  158.    NodeTime:Longint;
  159.  
  160. Function InitNodeList(DirName:String):Boolean; { True=Ok }
  161. Procedure CloseNodeListFiles;
  162. Procedure FindFirstSysop(SubStr:String;Var Find:FindNodeRec);
  163. Procedure FindNextSysop(Var Find:FindNodeRec);
  164. Procedure FindFirstNode(Zone,Net,Node,Point:Integer;Var Find:FindNodeRec);
  165. Procedure FindNextNode(Var Find:FindNodeRec);
  166. Procedure Split_Address(Address:String;Var Zone,Net,Node,Point:Integer);
  167.                                 { Splits a string-typed address into four    }
  168.                                 { numbers indicating Zone,Net,Node and Point }
  169. Function Word_Upcase(Frase:String):String;
  170.                                 { Converts a string into its upper-case }
  171.                                 { correspondent                         }
  172.  
  173. Implementation
  174. Uses
  175.    Dos;
  176.  
  177. Function FileExists(Nome_Del_File:String):Boolean;
  178. Var
  179.    TestFile:File;
  180.  
  181. Begin
  182.    Assign(TestFile,Nome_Del_File);
  183.    {$I-}
  184.    Reset(TestFile);
  185.    {$I+}
  186.    If IOResult=0 then
  187.    Begin
  188.       FileExists:=True;
  189.       Close(TestFile);
  190.    end
  191.    else
  192.       FileExists:=False;
  193. end;
  194.  
  195. Function Val2(St:String):Longint;
  196. Var
  197.    Res:Longint;
  198.    Err:Integer;
  199.  
  200. Begin
  201.    Val(St,Res,Err);
  202.    Val2:=Res;
  203. end;
  204.  
  205. Function Word_Upcase(Frase:String):String;
  206. Var
  207.    Kunta:Integer;
  208.  
  209. Begin
  210.    For Kunta:=1 to Length(Frase) do
  211.       Frase[Kunta]:=UpCase(Frase[Kunta]);
  212.    Word_UpCase:=Frase;
  213. end;
  214.  
  215. Function CmpSort(Stringa1,Stringa2:String):Byte;
  216. Var
  217.    Pos:Byte;
  218.    Exit:Byte;
  219.  
  220. Begin
  221.    Pos:=1;
  222.    Exit:=0;
  223.    While (Pos<=Length(Stringa1)) and (Pos<=Length(Stringa2))
  224.          and (Exit=0) do
  225.    Begin
  226.       If Stringa1[Pos]<Stringa2[Pos] then
  227.          Exit:=1
  228.       else
  229.       If Stringa1[Pos]>Stringa2[Pos] then
  230.          Exit:=2;
  231.       Inc(Pos);
  232.    end;
  233.    If Exit=0 then
  234.    Begin
  235.       If Length(Stringa1)<Length(Stringa2) then
  236.          Exit:=1
  237.       else
  238.       If Length(Stringa1)>Length(Stringa2) then
  239.          Exit:=2
  240.       else
  241.          Exit:=3;
  242.    end;
  243.    CmpSort:=Exit;
  244. end;
  245.  
  246. Function Convert_Name(FromStr:String):String; { Converts 'Silvan Calarco' into }
  247.                                               { 'CALARCO SILVAN'               }
  248.  
  249. Var
  250.    ResStr:String;
  251.    Cont:Byte;
  252.  
  253. Begin
  254.    ResStr:='';
  255.    FromStr:=Word_UpCase(FromStr)+' ';
  256.    While Length(FromStr)>0 do
  257.    Begin
  258.       Insert(Copy(FromStr,1,Pos(' ',FromStr)),ResStr,1);
  259.       Delete(FromStr,1,Pos(' ',FromStr));
  260.    end;
  261.    ResStr[0]:=Chr(Length(ResStr)-1);
  262.    For Cont:=2 to Length(ResStr) do
  263.       If (ResStr[Cont] in ['A'..'Z']) and (ResStr[Cont-1]<>#32) then
  264.           ResStr[Cont]:=Chr(Ord(ResStr[Cont])+32);
  265.    Convert_Name:=ResStr;
  266. end;
  267.  
  268. Function ReadVar(Var Linea:String):String;
  269. Var
  270.    C:Byte;
  271.  
  272. Begin
  273.    C:=1;
  274.    While (Linea[C]<>',') and (C<=Length(Linea)) do
  275.    Begin
  276.       If Linea[C]='_' then
  277.          Linea[C]:=' ';
  278.       Inc(C);
  279.    end;
  280.    If Pos(',',Linea)=0 then
  281.    Begin
  282.       ReadVar:=Copy(Linea,1,Pos(#13,Linea)-1);
  283.       Linea:='';
  284.    end
  285.    else
  286.    Begin
  287.       ReadVar:=Copy(Linea,1,Pos(',',Linea)-1);
  288.       Delete(Linea,1,Pos(',',Linea));
  289.    end;
  290. end;
  291.  
  292. Procedure Split_Address(Address:String;Var Zone,Net,Node,Point:Integer);
  293. Var
  294.    MomStr:String[5];
  295.  
  296. Begin
  297.    Address:=Word_UpCase(Address);
  298.    If Copy(Address,1,3)='ALL' then
  299.    Begin
  300.       Zone:=-1;Net:=-1;Node:=-1;Point:=-1;
  301.    end
  302.    else
  303.    Begin
  304.       Address:=Address+' ';
  305.       Zone:=Val2(Copy(Address,1,Pos(':',Address)-1));
  306.       If Zone=0 then
  307.          Zone:=2;
  308.       Delete(Address,1,Pos(':',Address));
  309.       If copy(Address,1,3)='ALL' then
  310.       Begin
  311.          Net:=-1;
  312.          Node:=-1;
  313.          Point:=-1;
  314.       end
  315.       else
  316.       Begin
  317.          If Pos('/',Address)<>0 then
  318.             Net:=Val2(Copy(Address,1,Pos('/',Address)-1));
  319.          Delete(Address,1,Pos('/',Address));
  320.          If Pos('.',Address)<>0 then
  321.          Begin
  322.             Node:=Val2(Copy(Address,1,Pos('.',Address)-1));
  323.             If Address[1]='.' then
  324.             Begin
  325.                Net:=0;
  326.                Node:=0;
  327.             end;
  328.             Delete(Address,1,Pos('.',Address));
  329.             Point:=Val2(Copy(Address,1,Pos(' ',Address)-1));
  330.          end
  331.          else
  332.          Begin
  333.             MomStr:=Copy(Address,1,Pos(' ',Address)-1);
  334.             If MomStr='ALL' then
  335.                Node:=-1
  336.             else
  337.                Node:=Val2(MomStr);
  338.             Point:=0;
  339.          end
  340.       end
  341.    end
  342. end;
  343.  
  344. Function TrovaTipo(Sub:String):Byte;
  345. Begin
  346.    If Sub='' then
  347.       TrovaTipo:=0
  348.    else
  349.    If Sub='ZONE' then
  350.       TrovaTipo:=ZC
  351.    else
  352.    If Sub='REGION' then
  353.       TrovaTipo:=Region
  354.    else
  355.    If Sub='HOST' then
  356.       TrovaTipo:=Host
  357.    else
  358.    If Sub='HUB' then
  359.       TrovaTipo:=Hub
  360.    else
  361.    If Sub='PVT' then
  362.       TrovaTipo:=Pvt
  363.    else
  364.    If Sub='HOLD' then
  365.       TrovaTipo:=InHold
  366.    else
  367.    If Sub='DOWN' then
  368.       TrovaTipo:=Down
  369.    else
  370.    If Sub='BOSS' then
  371.       TrovaTipo:=Boss;
  372. end;
  373.  
  374. Procedure RicavaRecord(Var St:String;Var BBSRecord:BBSRec;CurrZone,CurrNet,CurrNode:Integer);
  375. Var
  376.    Sub:String;
  377.    Err:Integer;
  378.  
  379. Begin
  380.    FillChar(BBSRecord,SizeOf(BBSRecord),#0);
  381.    With BBSRecord do
  382.    Begin
  383.       Sub:=Word_UpCase(ReadVar(St));
  384.       NodeType:=TrovaTipo(Sub);
  385.       Sub:=ReadVar(St);
  386.       If NodeType=ZC then
  387.       Begin
  388.          CurrZone:=Val2(Sub);
  389.          CurrNet:=0;
  390.          CurrNode:=-1;
  391.       end
  392.       else
  393.       If NodeType in [Region,Host] then
  394.       Begin
  395.          CurrNet:=Val2(Sub);
  396.          CurrNode:=-1;
  397.       end
  398.       else
  399.       If NodeType=Boss then
  400.       Begin
  401.          Delete(Sub,Pos(#13,Sub),1);
  402.          Split_Address(Sub,CurrZone,CurrNet,CurrNode,Err)
  403.       end
  404.       else
  405.       Begin
  406.          If CurrNode=-1 then
  407.             Node:=Val2(Sub)
  408.          else
  409.          Begin
  410.             Node:=CurrNode;
  411.             Point:=Val2(Sub);
  412.          end;
  413.       end;
  414.       Zone:=CurrZone;
  415.       Net:=CurrNet;
  416.       If NodeType<>Boss then
  417.       Begin
  418.          BBSName:=ReadVar(St);
  419.          Location:=ReadVar(St);
  420.          SysopName:=ReadVar(St);
  421.          Phone:=ReadVar(St);
  422.          BaudRate:=Val2(ReadVar(St));
  423.          Flags:=Copy(St,1,Pos(#13,St)-1);
  424.       end
  425.       else
  426.          Node:=CurrNode;
  427.    end;
  428. end;
  429.  
  430. Procedure FindRecord(NodoRec:NodeLocRec;Var ToRec:BBSRec);
  431. Var
  432.    Letti:Word;
  433.    Linea:String;
  434.  
  435. Begin
  436.    Case NodoRec.FileNum of
  437.       1:If FileRec(Nodelist1).Mode=FMClosed then
  438.            Reset(Nodelist1,1);
  439.       2:If FileRec(Nodelist2).Mode=FMClosed then
  440.            Reset(Nodelist2,1);
  441.    end;
  442.    Case NodoRec.FileNum of
  443.       1:Begin
  444.            Seek(Nodelist1,NodoRec.FilePos);
  445.            BlockRead(Nodelist1,Linea[1],255,Letti);
  446.            Linea[0]:=Chr(Letti);
  447.         end;
  448.       2:Begin
  449.            Seek(Nodelist2,NodoRec.FilePos);
  450.            BlockRead(Nodelist2,Linea[1],255,Letti);
  451.            Linea[0]:=Chr(Letti);
  452.         end;
  453.    end;
  454.    RicavaRecord(Linea,ToRec,0,0,-1);
  455.    ToRec.Zone:=NodoRec.Zone;
  456.    ToRec.Net:=NodoRec.Net;
  457.    ToRec.Node:=NodoRec.Node;
  458.    ToRec.Point:=NodoRec.Point;
  459. end;
  460.  
  461. Function ConfrNode(Zona1,Net1,Nodo1,Point1,Zona2,Net2,Nodo2,Point2:Integer):Boolean;
  462. Begin
  463.    If (Zona1=ALL) or
  464.       ((Zona1=Zona2) and (Net1=ALL)) or
  465.       ((Zona1=Zona2) and (Net1=Net2) and (Nodo1=ALL)) or
  466.       ((Zona1=Zona2) and (Net1=Net2) and (Nodo1=Nodo2) and (Point1=ALL)) or
  467.       ((Zona1=Zona2) and (Net1=Net2) and (Nodo1=Nodo2) and (Point1=Point2)) then
  468.          ConfrNode:=True
  469.       else
  470.          ConfrNode:=False;
  471. end;
  472.  
  473. Procedure FindNextNodeIndex(Var Find:FindNodeRec);
  474. Const
  475.    ActZone:Integer=-1;
  476.    ActNet:Integer=-1;
  477.  
  478. Var
  479.    Nodelist:NodeRec;
  480.    ActPos:Longint;
  481.    Esci:Boolean;
  482.  
  483. Begin
  484.    Seek(NodeIdxFile,Find.FPos1);
  485.    Repeat
  486.       Read(NodeIdxFile,Nodelist);
  487.       ActPos:=Nodelist.BBSRecord;
  488.       If Nodelist.NodeType=ZC then
  489.       Begin
  490.          ActZone:=Nodelist.Number;
  491.          ActNet:=0;
  492.       end
  493.       else
  494.       If Nodelist.NodeType in [Region,Host,Boss] then
  495.          ActNet:=Nodelist.Number;
  496.       Esci:=(ConfrNode(Find.SZone,Find.SNet,0,0,ActZone,ActNet,0,0));
  497.    Until Esci or Eof(NodeIdxFile);
  498.    Find.FPos1:=FilePos(NodeIdxFile);
  499.    If not(Esci) then
  500.       ActPos:=-1;
  501.    Find.FPos:=ActPos;
  502. end;
  503.  
  504. Procedure FindNextSysop(Var Find:FindNodeRec);
  505. Var
  506.    SysopList:SysopRec;
  507.    NodeLoc:NodeLocRec;
  508.  
  509. Begin
  510.    Seek(SysopListFile,Find.FPos);
  511.    SysopList.Name:='';
  512.    While not(Eof(SysopListFile)) and
  513.          (CmpSort(Find.SysStr,SysopList.Name) in [2,3]) do
  514.    Begin
  515.       Read(SysopListFile,SysopList);
  516.       If (Pos(Find.SysStr,SysopList.Name)=1) then
  517.       Begin
  518.          Seek(NodeLocFile,SysopList.BBSRecord);
  519.          Read(NodeLocFile,NodeLoc);
  520.          FindRecord(NodeLoc,Find.BBSRecord);
  521.          Find.FPos:=FilePos(SysopListFile);
  522.          Exit;
  523.       end
  524.    end;
  525.    Find.BBSRecord.SysopName:='';
  526. end;
  527.  
  528. Procedure FindNextNode(Var Find:FindNodeRec);
  529. Var
  530.    BBSList:NodeLocRec;
  531.  
  532. Begin
  533.    Seek(NodeLocFile,Find.FPos);
  534.    While not(Eof(NodeLocFile)) and (Find.FPos<>-1) do
  535.    Begin
  536.       Read(NodeLocFile,BBSList);
  537.       If ConfrNode(Find.SZone,Find.SNet,Find.SNode,Find.SPoint,
  538.                    BBSList.Zone,BBSList.Net,BBSList.Node,BBSList.Point) and
  539.          (BBSList.NodeType<>Boss) then
  540.       Begin
  541.          FindRecord(BBSList,Find.BBSRecord);
  542.          Find.FPos:=FilePos(NodeLocFile);
  543.          Exit;
  544.       end;
  545.       If not(ConfrNode(Find.SZone,Find.SNet,0,0,BBSList.Zone,BBSList.Net,0,0)) then
  546.       Begin
  547.          FindNextNodeIndex(Find);
  548.          If Find.FPos<>-1 then
  549.             Seek(NodeLocFile,Find.Fpos);
  550.       end;
  551.    end;
  552.    Find.BBSRecord.SysopName:='';
  553. end;
  554.  
  555. Procedure FindFirstSysop(SubStr:String;Var Find:FindNodeRec);
  556. Var
  557.    NodeIdx:NodeRec;
  558.    ActRec:Longint;
  559.    ExtrStr:String[4];
  560.  
  561. Begin
  562.    Find.SysStr:=Word_UpCase(Convert_Name(SubStr));
  563.    ExtrStr:=Copy(Find.SysStr,1,4);
  564.    Find.BBSRecord.SysopName:='';
  565.    Find.FPos:=0;
  566.    If FileRec(NodeLocFile).Mode=FMClosed then
  567.       Reset(NodeLocFile);
  568.    If FileRec(SysopListFile).Mode=FMClosed then
  569.       Reset(SysopListFile);
  570.    If FileRec(NodeIdxFile).Mode=FMClosed then
  571.       Reset(NodeIdxFile);
  572.    Seek(NodeIdxFile,0);
  573.    NodeIdx.SysopRecord:=0;
  574.    Repeat
  575.       ActRec:=NodeIdx.SysopRecord;
  576.       Read(NodeIdxFile,NodeIdx);
  577.    Until (CmpSort(ExtrStr,NodeIdx.Match) in [1,3]) or
  578.          Eof(NodeIdxFile);
  579.    Find.FPos:=ActRec;
  580.    FindNextSysop(Find);
  581. end;
  582.  
  583. Procedure FindFirstNode(Zone,Net,Node,Point:Integer;Var Find:FindNodeRec);
  584. Begin
  585.    Find.SZone:=Zone;
  586.    Find.SNet:=Net;
  587.    Find.SNode:=Node;
  588.    Find.SPoint:=Point;
  589.    Find.BBSRecord.SysopName:='';
  590.    If FileRec(NodeLocFile).Mode=FMClosed then
  591.       Reset(NodeLocFile);
  592.    If FileRec(SysopListFile).Mode=FMClosed then
  593.       Reset(SysopListFile);
  594.    If FileRec(NodeIdxFile).Mode=FMClosed then
  595.       Reset(NodeIdxFile);
  596.    Find.FPos1:=0;
  597.    FindNextNodeIndex(Find);
  598.    FindNextNode(Find);
  599. end;
  600.  
  601. Function Trova_File_Recente(Dir:String;Var Check:Boolean):String;
  602. Var
  603.    S:SearchRec;
  604.    ActTime:Longint;
  605.    ActFile:String[12];
  606.    Num,Err:Word;
  607.  
  608. Begin
  609.    ActTime:=0;
  610.    ActFile:='';
  611.    S.Name:='';
  612.    FindFirst(Dir,Archive,S);
  613.    While S.Name<>'' do
  614.    Begin
  615.       Err:=0;
  616.       If Check then
  617.          Val(Copy(S.Name,Pos('.',S.Name)+1,3),Num,Err);
  618.       If (S.Time>ActTime) and (Err=0) then
  619.       Begin
  620.          ActTime:=S.Time;
  621.          ActFile:=S.Name;
  622.       end;
  623.       S.Name:='';
  624.       FindNext(S);
  625.    end;
  626.    If (ActTime<NodeTime) and (NodeTime*ActTime<>0) then
  627.       Check:=True
  628.    else
  629.       Check:=False;
  630.    If ActFile='' then
  631.       Dir:=''
  632.    else
  633.    While (Dir[Length(Dir)]<>'\') and (Length(Dir)>0) do
  634.       Delete(Dir,Length(Dir),1);
  635.    Trova_File_Recente:=Dir+ActFile;
  636. end;
  637.  
  638. Function InitNodeList(DirName:String):Boolean;
  639. Var
  640.    C:Boolean;
  641.    S:SearchRec;
  642.  
  643. Begin
  644.    If (DirName[Length(DirName)]<>'\') and (Length(DirName)>0) then
  645.       DirName:=DirName+'\';
  646.    DirName:=FExpand(DirName);
  647.    Assign(NodeLocFile,DirName+'nodeloc.wnl');
  648.    Assign(SysopListFile,DirName+'syslist.wnl');
  649.    Assign(NodeIdxFile,DirName+'nodeidx.wnl');
  650.    C:=True;
  651.    Assign(Nodelist1,Trova_File_Recente(DirName+'NODELIST.*',C));
  652.    Assign(Nodelist2,DirName+'ALTNODE.WNL');
  653.    InitNodeList:=FileExists(DirName+'syslist.wnl') and
  654.                  FileExists(DirName+'nodeidx.wnl') and
  655.                  FileExists(DirName+'nodeloc.wnl');
  656.    S.Name:='';
  657.    FindFirst(DirName+'NODELOC.WNL',Archive,S);
  658.    If S.Name<>'' then
  659.       NodeTime:=S.Time
  660.    else
  661.       NodeTime:=0;
  662. end;
  663.  
  664. Procedure CloseNodeListFiles;
  665. Begin
  666.    If FileRec(NodeLocFile).Mode=FMInOut then
  667.       Close(NodeLocFile);
  668.    If FileRec(SysopListFile).Mode=FMInOut then
  669.       Close(SysopListFile);
  670.    If FileRec(NodeIdxFile).Mode=FMInOut then
  671.       Close(NodeIdxFile);
  672.    If FileRec(NodeList1).Mode=FMInOut then
  673.       Close(NodeList1);
  674.    If FileRec(NodeList2).Mode=FMInOut then
  675.       Close(NodeList2);
  676. end;
  677.  
  678. Begin
  679. end.
  680.